// 危险点管理

import request from "./axios";

export const SafetyRiskPointAPI = {
  getList: (params) => request.get("/entities/SafetyRiskPoint", { params }),

  create: (data) => request.post("/entities/SafetyRiskPoint", data),

  update: (id, data) => request.put(`/entities/SafetyRiskPoint/${id}`, data),

  delete: (id) => request.delete(`/entities/SafetyRiskPoint/${id}`),

  // 修改后的下载模板接口
  importTemplate: () =>
    request.get(`/entities/SafetyRiskPoint/importTemplate`, {
      responseType: "blob", // 关键：指定响应类型为二进制流
    }),
  // 导入
  // 修改后的导入接口（支持文件上传）
  import: (file) => {
    // 创建FormData对象用于传输文件
    const formData = new FormData();
    formData.append("file", file); // 假设后端接收文件的参数名为file
    return request.post(`/entities/SafetyRiskPoint/import`, formData, {
      headers: {
        "Content-Type": "multipart/form-data", // 上传文件需指定该Content-Type
      },
    });
  },
};
